﻿using Newtonsoft.Json;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Easy.BLL;
using Easy.Operation.Data;

namespace Easy.Web.Pages.DataPages
{
    public partial class LinkView : BasePage
    {
        public string EntityName;
        public string ViewName;
        protected void Page_Load(object sender, EventArgs e)
        {
            EntityName = (Request["entityname"] == null ? Request["entityBname"] : Request["entityname"]).ToLower();
            ViewName = Request["viewname"] == null ? "DefaultView" : Request["viewname"];
            PageView view = new PageView(EntityName, this.GetSystemUser(), ViewName);
            this.CoreScript.Text = string.Format(@"<script  type=""text/javascript"">
                                                    var EntityName='{0}';
                                                    var EntityViews={1};
                                                    var ViewName='{2}';
                                                    var Privilege={3};
                                                    var FunctionPrivilege={4};
                                                    </script>", 
                                                    view.EntityName,                                                  
                                                    JsonConvert.SerializeObject(view.ViewsPC),
                                                    view.ViewName,
                                                    JsonConvert.SerializeObject(view.UserPrivilege),
                                                    JsonConvert.SerializeObject(view.FunctionPrivilege));
        }
    }
}